from django.http import JsonResponse


def decorator_user(func):
    def warpper(request, *args, **kwargs):
        if request.user.is_authenticated:
            # 登录则执行
            return func(request, *args, **kwargs)
        else:
            return JsonResponse({'errmsg': '请登录后重试', })

    return warpper
